package com.ygxsk.carhome.ui.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.CarAttestation;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.StringCodeUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-17  16:07
 * @Description:认证管理的 主页列表适配器
 */
public class AuthManageItemAdapter extends BaseQuickAdapter<CarAttestation, BaseViewHolder> {

    public AuthManageItemAdapter(int layoutResId) {
        super(layoutResId);
    }

    public AuthManageItemAdapter(int layoutResId, @Nullable List<CarAttestation> data) {
        super(layoutResId, data);

        addChildClickViewIds(R.id.textvieweditviewphoneinauth);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CarAttestation authManageItemBean) {

        if (authManageItemBean != null) {

            //姓名
            String name = authManageItemBean.getCustomerName();
            //手机号
            String phone = authManageItemBean.getCustomerPhone();
            //车辆型号
            String carModel = authManageItemBean.getCarModel();
            //认证的体系
            String authSystem = authManageItemBean.getAttestationNames();
            //状态的内容--主要是分配状态
            String satateItem = authManageItemBean.getStatusName();

            //findviews
            //姓名
            //评估的方式标签
            TextView textViewPersonName = (TextView) baseViewHolder.getView(R.id.textviewpersonnameinauth);
            //手机号
            TextView textViewEditViewPhone = (TextView) baseViewHolder.getView(R.id.textvieweditviewphoneinauth);
            //车辆型号
            TextView textViewCarModelValue = (TextView) baseViewHolder.getView(R.id.textviewcarmodelvalueauth);
            //车辆评估认证的体系
            TextView textViewCarAuthSystem = (TextView) baseViewHolder.getView(R.id.textviewcarsystemvalue);

            //底部的一个高度占位
            TextView textViewHelpInLeadMainBottom = (TextView) baseViewHolder.getView(R.id.textviewhelpinleadmainbottom);

            //评估的方式标签
            RoundTextView textViewEvaluateFormWhere = (RoundTextView) baseViewHolder.getView(R.id.textviewauthstate);
            //分配状态
//            TextView textViewPersonAuthState = (TextView) baseViewHolder.getView(R.id.textviewauthstate);

            //位置的position
            int indexPosition = getItemPosition(authManageItemBean);
            if (indexPosition == getData().size() - 1) {
                textViewHelpInLeadMainBottom.setVisibility(View.VISIBLE);
            } else {
                textViewHelpInLeadMainBottom.setVisibility(View.GONE);
            }

            //该人员的状态：
            CommUtils.setText(textViewPersonName, name);
            //该人员的手机号
//            CommUtils.setText(textViewEditViewPhone, phone);
            CommUtils.setText(textViewEditViewPhone, StringCodeUtils.mobileEncrypt(phone));

            //该车辆的型号
            CommUtils.setText(textViewCarModelValue, carModel);
            //车辆的评估认证体系
            CommUtils.setText(textViewCarAuthSystem, authSystem);
            //该人员该车辆的状态
            CommUtils.setText(textViewEvaluateFormWhere, satateItem);


        }

    }
}
